<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台控制</title>
</head>
<link rel="stylesheet" href="../js/bootstrap3/css/bootstrap.min.css">
<link rel="stylesheet" href="../js/bootstrap-treeview/bootstrap-treeview.min.css">
<link rel="stylesheet" href="../js/bootStrap-addTabs/bootstrap.addtabs.css">
<script type="text/javascript" src="../js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../js/bootstrap3/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-treeview/bootstrap-treeview.min.js"></script>
<script type="text/javascript" src="../js/bootStrap-addTabs/bootstrap.addtabs.min.js"></script>
<body>

<!-- 导航栏 -->
<nav class="navbar navbar-inverse navbar fixed-top">
    <!-- 固定布局 -->
    <div class="container">
        <!-- 头部信息 -->
        <div class="nav-header">
            <!-- 连接 -->
            <a class="navbar-brand" href="#">二手车后端调控</a>
            <!--登录用户-->
            <div class="navbar-brand pull-right">
                <!--<img id="adminimg" src="" alt="照片丢失了" width="30px" height="30px" style="float: left">-->
                <span id="admin" style="float: left">当前管理员登录</span>
            </div>

            <!-- 搜索框 -->
            <!--<form class="navbar-form pull-right">
                <input type="text" class="search-query" placeholder="Search">
            </form>-->
        </div>
    </div>
</nav>

<!-- 内容 -->
<div class="container-fluid">
    <div class="row-fluid">
        <div class="col-xs-2">
            <!--Sidebar content-->
            <div id="myTree"></div>
        </div>
        <div class="col-xs-10">
            <!--Body content-->
            <!-- 选项卡 -->
            <div id="myTabs">
                <ul class="nav nav-tabs" id="tablist">
                    <li><!--  class="active" 默认被打开的活动窗口 -->
                        <a href="#" data-toggle="tab">首页</a>
                    </li>
                </ul>
                <!-- 选项卡内容,由树形菜单的连接指定 -->
                <div class="tab-content">
                    <div class="tab-pane active" id="home"></div>
                </div>
            </div>
            <div>
                <img src="../images/R-C.gif" width="200px" style="position:fixed;margin-left: -50px; margin-top: 490px">
            </div>
        </div>
    </div>
</div>

</body>
<script>
    
    $(function(){
        initAdmin();
        initMyTree();
    })

    //初始化当前管理员
    function initAdmin(){
        $.ajax({
            url: "../admin/getAdmin",
            type: "post",
            dataType: "json",
            async: true,
            success:function (data){
                $("#adminimg").attr("src","../"+data.adminimg);
                $("#admin").html("<font>"+data.rolename+" | "+data.adminname+"</font><a href='javascript:exit()'>注销</a>");
            }
        })
    }

    //初始化树型菜单那
    function initMyTree(){
        $.ajax({
            url:"../tree/queryTreeList",
            type:"get",
            dataType:"json",
            async:true,
            success:function(data){
                $("#myTree").treeview({
                    data: data,					//列表树上显示的数据
                    backColor: "#222222",		//列表的背景色
                    borderColor: "#000000",		//列表背景的边框色
                    onhoverColor: "#FFFFFF",	//鼠标划过列表的背景色		
                    color: "#9D9D9D",			//列表字体色
                    selectedIcon: "glyphicon glyphicon-check",	//设置所有被选择的节点上的默认图标。
                    onNodeSelected:function(event, node){		//nodeSelected 事件，必须使用 on 开头 原首字母大写，	node 当前节点
                        $.addtabs({iframeHeight:"800px"});		//默认选项卡打开的高度
                        $.addtabs.add({
                            id:node.id,
                            title:node.text,
                            url:"../"+node.url
                        })
                    }
                })
            },error:function(){
                alert("查询Tree失败！");
            }
        })
    }

    //注销用户
    function exit(){
        $.ajax({
            url: "../admin/exit",
            type: "get",
            success: function (data){
                window.top.location.href="../backstage/login";
            }
        })
    }
    
</script>
</html>